if(LL_VN_Mobj ~= nil)
	return
end

// no netsync, they're constant i.e. never change, so do desync potential
local PLINTH_FRAMES = 3
local PLINTH_SCALE = 7 * FRACUNIT / 2
local GRAPEVINE_SCALE = 5 * FRACUNIT

// map editor frame-pick utility for the plinth mobj
// rather than one mobj per plinth variant, now each
// plinth variant is a frame in the one sprite of the
// plinth mobj
// even though we don't use mapthing in here, it has to
// be in this hook and not mobjspawn because this is
// the only one where we guarantee the thing_arg we
// need to read is in our control
// a plinth spawned any other way will rest on the 0
// frame by the FREESLOT definition anyway
local function OnMapThingSpawn_Plinth(mo, mt)
	local frameIndex = (mo.args[0] % PLINTH_FRAMES + PLINTH_FRAMES) % PLINTH_FRAMES
	mo.frame = (mo.frame & ~FF_FRAMEMASK) | frameIndex
end

// force the plinth mobj to be of a certain scale
// instantly upon spawn
local function OnMobjSpawn_Plinth(mo)
	mo.destscale = FixedMul(mo.destscale, PLINTH_SCALE)
	P_SetScale(mo, mo.destscale)
end

local function OnMobjSpawn_Grapevine(mo)
	mo.destscale = FixedMul(mo.destscale, GRAPEVINE_SCALE)
	P_SetScale(mo, mo.destscale)
end

local function OnMobjThinker_WineSplash(mo)
	local spoutHeight = LL_VN_Comms.getField("wine_spoutHeight")
	
	if( spoutHeight ~= nil ) then
		mo.z = spoutHeight
		mo.destscale = FRACUNIT
	else
		mo.destscale = 0
	end
	
	P_SetScale(mo, mo.destscale)
end

local mobjLib = {}
mobjLib.mapThingSpawn_plinth = {}
mobjLib.mapThingSpawn_plinth[1] = OnMapThingSpawn_Plinth
mobjLib.mapThingSpawn_plinth[2] = MT_LOONIEVINO_PLINTH
mobjLib.mobjSpawn_plinth = {}
mobjLib.mobjSpawn_plinth[1] = OnMobjSpawn_Plinth
mobjLib.mobjSpawn_plinth[2] = MT_LOONIEVINO_PLINTH
mobjLib.mobjSpawn_grapevine = {}
mobjLib.mobjSpawn_grapevine[1] = OnMobjSpawn_Grapevine
mobjLib.mobjSpawn_grapevine[2] = MT_LOONIEVINO_GRAPEVINE
mobjLib.mobjThinker_wineSplash = {}
mobjLib.mobjThinker_wineSplash[1] = OnMobjThinker_WineSplash
mobjLib.mobjThinker_wineSplash[2] = MT_LOONIEVINO_WINESPLASH
rawset(_G, "LL_VN_Mobj", mobjLib)